/*
 * Copyright (C) 2016 The Android Open Source Project
 *  Created by  Ant  2016/10/3  15:49
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.ant.birds.activities;

import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.ant.birds.MainActivity;
import com.ant.birds.R;
import com.ant.utils.base.BaseActivity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by baichuan on 2016/10/3.
 */
public class IndexActivity extends BaseActivity {
    private ListView lv;
    private List<String> sls;
    private List<Class> cls;
    private ArrayAdapter<String> adatper;


    @Override
    public int getLaout() {
        sls = new ArrayList<>();
        cls = new ArrayList<>();
        return R.layout.ac_index_layout;
    }

    @Override
    public void initView() {
        lv = (ListView) findViewById(R.id.ac_index_layout_listview);

    }


    public void getData() {
        sls.add("game");
        cls.add(MainActivity.class);
        sls.add("shareTest");
        cls.add(ShareTestActivity.class);
    }

    @Override
    public void initData() {

        getData();
        adatper = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, sls);
        lv.setAdapter(adatper);
    }

    @Override
    public void initListener() {
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                IndexActivity.this.
                        startActivity(new Intent(IndexActivity.this, cls.get(i)));
            }
        });

    }

}
